package com.shwread.android.qysw.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

import com.shwread.android.qysw10000182.R;
import com.shwread.android.ui.customview.GoodsAdapter;

import java.util.ArrayList;

import logic.bean.OrderDetailColum;
import logic.bean.UserAddressInfo;


/**
 * 确认收货
 * 
 * @author xuzhijun
 * @date 2015年3月24日
 */
public class ConfirmReceiveActivity
        extends
        BaseBusinessActivity
        implements
        OnClickListener
{
	
	private Context                 context;
	private ConfirmReceiveActivity  bActivity;
	
	private TextView                tvTitle;
	private Button                  btnHome;
	private Button                  btnBack;
	
	private LayoutInflater          inflater;
	private ListView                listView;
	private View                    topView;
	private View                    bottomView;
	private GoodsAdapter            adapter;
	
//	private OrderInfo               orderInfo;
	private UserAddressInfo             addressInfo;
	private ArrayList<OrderDetailColum> goodsList;
	
	private Button                  btnConfirm;
	
	@Override
	public Handler getUIHandler() {
		// TODO Auto-generated method stub
		return null;
	}
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.confirm_receive);
		context = this;
		bActivity = this;
		inflater = LayoutInflater.from(context);
		initView();
		initData();
		setListener();
		
	}
	
	private void initView() {
		//Title
		tvTitle = (TextView) findViewById(R.id.common_header_name);
		tvTitle.setText(getResources().getString(R.string.confirm_receive));
		btnHome = (Button) findViewById(R.id.common_header_home);
		btnHome.setVisibility(View.VISIBLE);
		btnBack = (Button) findViewById(R.id.common_header_back);
		btnBack.setVisibility(View.VISIBLE);
		
		listView = (ListView) findViewById(R.id.confirm_receive_listview);
		
		topView = inflater.inflate(R.layout.confirm_receive_top, null);
		bottomView = inflater.inflate(R.layout.confirm_receive_bottom, null);
		btnConfirm = (Button) bottomView.findViewById(R.id.confirm_receive_confirm_btn);
		listView.addHeaderView(topView);
		listView.addFooterView(bottomView);
		
	}
	
	private void initData() {
		InitOrder();
		
	}
	
	private void setListener() {
		btnHome.setOnClickListener(this);
		btnBack.setOnClickListener(this);
		btnConfirm.setOnClickListener(this);
	}
	
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
			case R.id.common_header_home:
//				startActivity(new Intent(this, MainActivity.class));
				BaseSimpleActivity.gotoMainActivity();
				break;
			case R.id.common_header_back:
				bActivity.finish();
				break;
			case R.id.confirm_receive_confirm_btn:
				startActivity(new Intent(context, OrderDetailActivity.class));
				break;
		
		}
	}
	
	private void InitOrder() {
//		addressInfo = new UserAddressInfo("李四", "15444444444", "浙江省杭州市江干区", "白羊大街二号大街一号杭州电子科技大学");
		goodsList = new ArrayList<OrderDetailColum>();
		
//		ConfirmOrderBean goods1 = new ConfirmOrderBean(12345001L, "筷子", "筷子架筷子创意竹木日式料理餐具韩国家用餐具xx", 28.00, 11, 2, "普通包装", "http://png.findicons.com/files/icons/2117/nuove/128/eclipse.png");
//		goodsList.add(goods1);
//		ConfirmOrderBean goods2 = new ConfirmOrderBean(12345002L, "碗", "碗碗碗碗碗碗碗碗碗xxasa", 30.00, 14.32, 4, "精装", "https://ss1.baidu.com/6ONXsjip0QIZ8tyhnq/it/u=3415372198,2864505025&fm=58");
//		goodsList.add(goods2);
//		ConfirmOrderBean goods3 = new ConfirmOrderBean(12345003L, "筷子d", "筷子意竹木日式料理餐具韩国家用餐具weq", 23.00, 34.23, 1, "普通包装", "http://png.findicons.com/files/icons/2117/nuove/128/eclipse.png");
//		goodsList.add(goods3);
//		ConfirmOrderBean goods4 = new ConfirmOrderBean(12345003L, "筷子d", "筷子意竹木日式料理餐具韩国家用餐具weq", 23.00, 34.23, 1, "普通包装", "http://png.findicons.com/files/icons/2117/nuove/128/eclipse.png");
//		goodsList.add(goods4);
//		ConfirmOrderBean goods5 = new ConfirmOrderBean(12345003L, "筷子d", "筷子意竹木日式料理餐具韩国家用餐具weq", 23.00, 34.23, 1, "普通包装", "http://png.findicons.com/files/icons/2117/nuove/128/eclipse.png");
//		goodsList.add(goods5);
//		ConfirmOrderBean goods6 = new ConfirmOrderBean(12345003L, "筷子d", "筷子意竹木日式料理餐具韩国家用餐具weq", 23.00, 34.23, 1, "普通包装", "http://png.findicons.com/files/icons/2117/nuove/128/eclipse.png");
//		goodsList.add(goods6);
		
//		orderInfo = new OrderInfo(addressInfo, goodsList, "挑一个好的哦!");
//		orderInfo.setComment(true);
		
//		adapter = new GoodsAdapter(context, goodsList);
		listView.setAdapter(adapter);
	}
	
}
